package com.ipet.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ipet.user.mapper.UserMapper;
import com.ipet.user.pojo.User;
import com.ipet.user.service.UserService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper , User> implements UserService {

    @Override
    public PageInfo<User> findUserPage(Integer pageNo, Integer pageSize) {
        PageHelper.startPage(pageNo , pageSize);
        List<User> userList = this.baseMapper.selectList(null);
        PageInfo<User> userPageInfo = new PageInfo<>(userList);
        return userPageInfo;
    }

    @Override
    public PageInfo<User> getUserByName(String username , Integer pageNo , Integer pageSize) {
        PageHelper.startPage(pageNo , pageSize);
        List<User> userList = this.baseMapper.selectList(new QueryWrapper<User>().like("username", username));
        PageInfo<User> userPageInfo = new PageInfo<>(userList);
        return userPageInfo;
    }
}
